﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using DAL;
using Utility;

namespace BUS
{
    public class Tbl_DatHang_BUS
    {
        public static Tbl_DatHang_Collection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            Tbl_DatHang_DAL dhDAL = new Tbl_DatHang_DAL();
            return dhDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Tbl_DatHang_Collection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            Tbl_DatHang_DAL dhDAL = new Tbl_DatHang_DAL();
            return dhDAL.Get(cri.Criter, 0, 0, Tbl_DatHang_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static Tbl_DatHang_Entities GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Tbl_DatHang_Columns.STT.ToString(), Condition.EQUAL, iD);
            Tbl_DatHang_DAL dhDAL = new Tbl_DatHang_DAL();
            Tbl_DatHang_Collection dhCollection = dhDAL.Get(cri.Criter, 0, 0, Tbl_DatHang_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dhCollection.Count > 0)
                return dhCollection[0];
            return null;
        }

        public static void Insert(Tbl_DatHang_Entities dh)
        {
            Tbl_DatHang_DAL dhDAL = new Tbl_DatHang_DAL();
            dhDAL.insert(dh);
        }
        public static void Update(Tbl_DatHang_Entities dh)
        {
            Tbl_DatHang_DAL dhDAL = new Tbl_DatHang_DAL();
            dhDAL.Update(dh);
        }
        public static void Delete(int id)
        {
            Tbl_DatHang_DAL dhDAL = new Tbl_DatHang_DAL();
            dhDAL.Delete(id);
        }
    }
}
